set(XF_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../include" ${XF_INCLUDE_DIRS})
set(XF_LIBRARY_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../libs/x64" ${XF_LIBRARY_DIRS})

pkg_check_modules(ALSA "alsa" REQUIRED)

include_directories(
    ${GTK3_INCLUDE_DIRS}
    ${DBUS_GLIB_INCLUDE_DIRS}
    ${X11_XTest_INCLUDE_PATH}
    ${PROJECT_BINARY_DIR}
    ${CMAKE_CURRENT_BINARY_DIR}
    ${XF_INCLUDE_DIRS}   
)
FIND_LIBRARY(RUNTIME_LIB rt /usr/lib  /usr/local/lib )
link_libraries( ${RUNTIME_LIB})
link_directories(
    ${GTK3_LIBRARY_DIRS}
    ${DBUS_GLIB_LIBRARY_DIRS}
    ${XF_LIBRARY_DIRS}
)

find_program(DBUSBINDINGTOOL dbus-binding-tool)

set(SHUOXIE_SRCS
    service.c
    handwrite.c
    stroke.c
    shuoxie-service.h   
    intext.c    
    iat_record.c
    linuxrec.c
    speech_recognizer.c
    loginDialog.c
    set_dialog.c
    rw_config.c
)

add_custom_command(
    OUTPUT shuoxie-service.h
    COMMAND ${DBUSBINDINGTOOL} --mode=glib-server
                               --output=shuoxie-service.h
                               --prefix=shuoxie_service
                                ${CMAKE_CURRENT_SOURCE_DIR}/shuoxie-service.xml
    DEPENDS shuoxie-service.xml
)

add_executable(shuoxie ${SHUOXIE_SRCS})
target_link_libraries(shuoxie
    ${GTK3_LIBRARIES}
    ${DBUS_GLIB_LIBRARIES}
    ${X11_XTest_LIB}
    ${X11_LIBRARIES}
    #-lm  shuxie stdc++        
    ${XF_LIBRARY_DIRS}
    -lshuxie
    -lmsc -lrt -ldl -lpthread -lasound    
    )

install(TARGETS shuoxie DESTINATION bin)
install(FILES ${XF_LIBRARY_DIRS}/libmsc.so DESTINATION lib)

install(FILES ${XF_LIBRARY_DIRS}/libshuxie.so RENAME libshuxie.so.1  DESTINATION lib  )


#execute_process(COMMAND ln -s ${LIBDIR}/libshuxie.so.1.0.0 ${LIBDIR}/libshuxie.so)
